package ShareLife.gar;

import android.content.Context;
import android.graphics.Bitmap;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ImageView;

public class ImageAdapter extends BaseAdapter {

	private Context mContext;
	private Bitmap[] bitmaparray;
	public ImageAdapter(Context c) {
		mContext = c;
	}
	public void setBitmapArray(Bitmap[] arrayBitmap)
	{
		bitmaparray= arrayBitmap;
		
	}
	
	public int getCount() {
		
			return  bitmaparray.length;
	}

	
	public Object getItem(int position) {
		return position;
	}

	
	public long getItemId(int position) {
		return position;
	}

	public View getView(int position, View convertView, ViewGroup parent) {
		ImageView imageView;
		if (convertView == null) {
			imageView = new ImageView(mContext);
			imageView.setLayoutParams(new GridView.LayoutParams(40, 40));
			imageView.setScaleType(ImageView.ScaleType.FIT_CENTER);
		} else {
			imageView = (ImageView) convertView;
		}

		imageView.setImageBitmap(bitmaparray[position]);
		return imageView;
	}


}
